import { WeaTools } from 'ecCom';

export const trans = (str = '') => {
  const arr = str.split('&');
  const obj = {};
  arr.forEach(item => {
    if (item) {
      // const _item = item.split('=');
      // obj[_item[0]] = _item[1];
      let index = item.indexOf('=');
      let _key = item.slice(0, index);
      let _value = item.slice(index + 1);
      obj[_key] = _value;
    }
  });
  return obj;
};

export const callApi = (url, method, params, type) => {
  return WeaTools.callApi(url, method, { ...params, ...trans(window.__moudleParams) }, type);
};
